// 如果没有通过拦截器配置域名的话，可以在这里写上完整的URL(加上域名部分)
// region 应用相关接口 +++++
// 站点信息
let apiAppDetail = '/vaccine/app/detail';
// 文本短信
let apiSmsText = '/vaccine/sms/text';
// 微信JSSDK
let apiWxJsSdkConfig = '/wechat/official/jssdk_config';
// endregion

let apiWxUserDetail = '/wechat/user/detail';

// region 公共字典 +++++
let apiAreaSelectData = '/vaccine/area/uview_select';
let apiTypeSelectData = '/vaccine/type/uview_select';
let apiHospitalSelectData = '/vaccine/hospital/uview_select';
// endregion

// 个人提交
let apiPlanPersonCreate = '/vaccine/plan_person/create';
let apiPlanPersonUpdate = '/vaccine/plan_person/update';
let apiPlanPersonList = '/vaccine/plan_person/retrieve';
let apiPlanPersonDetail = '/vaccine/plan_person/detail';

// 单位提交
let apiPlanUnitCreate = '/vaccine/plan_unit/create';
let apiPlanUnitList = '/vaccine/plan_unit/retrieve';
let apiPlanUnitDetail = '/vaccine/plan_unit/detail';

let apiHospitalList = '/vaccine/hospital/retrieve';
let apiHospitalDetail = '/vaccine/hospital/detail';
let apiHospitalRecordCreate = '/vaccine/hospital_record/create';

let apiManageDetail = '/vaccine/manage/detail';
let apiManageCreate = '/vaccine/manage/create';
let apiManagePlanUnitList = '/vaccine/manage_plan_unit/retrieve';
let apiManagePlanPersonList = '/vaccine/manage_plan_person/retrieve';

let apiProductList = '/vaccine/product/retrieve';
let apiProductDetail = '/vaccine/product/detail';

let apiProductOrderList = '/vaccine/product_order/retrieve';
let apiProductOrderCreate = '/vaccine/product_order/create';
let apiProductOrderDetail = '/vaccine/product_order/detail';

/**
 * 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作，更多内容详见uView对拦截器的介绍部分：
 * https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
 */
const install = (Vue, vm) => {
    // region 应用相关接口 +++++
    // 获取信息
    let appDetail = (params = {}) => vm.$u.get(apiAppDetail, params).catch((error) => {
        console.log('接口错误-->apiAppDetail:', error);
        return false;
    });
    // 短信发送
    let smsText = (params = {}) => vm.$u.post(apiSmsText, params).catch((error) => {
        console.log('接口错误-->apiSmsText:', error);
        vm.$u.toast(error.msg);
        return false;
    });
    let wxUserDetail = (params = {}) => vm.$u.get(apiWxUserDetail, params).catch((error) => {
        console.log('接口错误-->apiWxUserDetail:', error);
        return false;
    });
    let wxJsSdkConfig = (params = {}) => vm.$u.post(apiWxJsSdkConfig, params).catch((error) => {
        console.log('接口错误-->apiWxJsSdkConfig:', error);
        vm.$u.toast(error.msg);
        return false;
    });
    // endregion
    
    let planPersonCreate = (params = {}) => vm.$u.post(apiPlanPersonCreate, params).catch((error) => {
        console.log('接口错误-->apiPlanPersonCreate:', error);
        vm.$u.toast(error.msg);
        return false;
    });
	let planPersonUpdate = (params = {}) => vm.$u.post(apiPlanPersonUpdate, params).catch((error) => {
	    console.log('接口错误-->apiPlanPersonUpdate:', error);
	    vm.$u.toast(error.msg);
	    return false;
	});
    let planPersonList = (params = {}) => vm.$u.get(apiPlanPersonList, params).catch((error) => {
        console.log('接口错误-->apiPlanPersonList:', error);
        return false;
    });
    let planPersonDetail = (params = {}) => vm.$u.get(apiPlanPersonDetail, params).catch((error) => {
        console.log('接口错误-->apiPlanPersonDetail:', error);
        return false;
    });
    
    let planUnitCreate = (params = {}) => vm.$u.post(apiPlanUnitCreate, params).catch((error) => {
        console.log('接口错误-->apiPlanUnitCreate:', error);
        vm.$u.toast(error.msg);
        return false;
    });
    let planUnitList = (params = {}) => vm.$u.get(apiPlanUnitList, params).catch((error) => {
        console.log('接口错误-->apiPlanUnitList:', error);
        return false;
    });
    let planUnitDetail = (params = {}) => vm.$u.get(apiPlanUnitDetail, params).catch((error) => {
        console.log('接口错误-->apiPlanUnitDetail:', error);
        return false;
    });
    
    let hospitalList = (params = {}) => vm.$u.get(apiHospitalList, params).catch((error) => {
        console.log('接口错误-->apiHospitalList:', error);
        return false;
    });
    let hospitalDetail = (params = {}) => vm.$u.get(apiHospitalDetail, params).catch((error) => {
        console.log('接口错误-->apiHospitalDetail:', error);
        return false;
    });
    
    let hospitalRecordCreate = (params = {}) => vm.$u.post(apiHospitalRecordCreate, params).catch((error) => {
        console.log('接口错误-->apiHospitalRecordCreate:', error);
        vm.$u.toast(error.msg);
        return false;
    });
    
    let areaSelectData = (params = {}) => vm.$u.get(apiAreaSelectData, params).catch((error) => {
        console.log('接口错误-->apiAreaSelectData:', error);
        return false;
    });
    let typeSelectData = (params = {}) => vm.$u.get(apiTypeSelectData, params).catch((error) => {
        console.log('接口错误-->apiTypeSelectData:', error);
        return false;
    });
    let hospitalSelectData = (params = {}) => vm.$u.get(apiHospitalSelectData, params).catch((error) => {
        console.log('接口错误-->apiHospitalSelectData:', error);
        return false;
    });
    
    let manageDetail = (params = {}) => vm.$u.get(apiManageDetail, params).catch((error) => {
        console.log('接口错误-->apiManageDetail:', error);
        // vm.$u.toast(error.msg);
        return false;
    });
    let manageCreate = (params = {}) => vm.$u.post(apiManageCreate, params).catch((error) => {
        console.log('接口错误-->apiManageCreate:', error);
        vm.$u.toast(error.msg);
        return false;
    });
    let managePlanUnitList = (params = {}) => vm.$u.get(apiManagePlanUnitList, params).catch((error) => {
        console.log('接口错误-->apiManagePlanUnitList:', error);
        return false;
    });
    let managePlanPersonList = (params = {}) => vm.$u.get(apiManagePlanPersonList, params).catch((error) => {
        console.log('接口错误-->apiManagePlanPersonList:', error);
        return false;
    });
	
	let productList = (params = {}) => vm.$u.get(apiProductList, params).catch((error) => {
	    console.log('接口错误-->apiProductList:', error);
	    return false;
	});
	let productDetail = (params = {}) => vm.$u.get(apiProductDetail, params).catch((error) => {
	    console.log('接口错误-->apiProductDetail:', error);
	    return false;
	});
	
	let productOrderList = (params = {}) => vm.$u.get(apiProductOrderList, params).catch((error) => {
	    console.log('接口错误-->apiProductOrderList:', error);
	    return false;
	});
	let productOrderCreate = (params = {}) => vm.$u.post(apiProductOrderCreate, params).catch((error) => {
	    console.log('接口错误-->apiProductOrderCreate:', error);
	    vm.$u.toast(error.msg);
	    return false;
	});
	let productOrderDetail = (params = {}) => vm.$u.get(apiProductOrderDetail, params).catch((error) => {
	    console.log('接口错误-->apiProductOrderDetail:', error);
	    return false;
	});
    
    // 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
    vm.$u.api = {
        // region 应用相关接口 +++++
        appDetail,
        smsText,
        wxUserDetail,
        wxJsSdkConfig,
        // endregion
        areaSelectData,
        typeSelectData,
        hospitalSelectData,
        
        planPersonCreate,
		planPersonUpdate,
        planPersonList,
        planPersonDetail,
        
        planUnitCreate,
        planUnitList,
        planUnitDetail,
        
        hospitalList,
        hospitalDetail,
        hospitalRecordCreate,
        
        manageDetail,
        manageCreate,
        managePlanPersonList,
        managePlanUnitList,
		
		productList,
		productDetail,
		
		productOrderList,
		productOrderCreate,
		productOrderDetail,
    };
}
export default {
    install
}
